﻿@using NewLife;
@using NewLife.Cube
@using XCode
@{
    var entity = Model as IEntity;
    var set = ViewBag.PageSetting as PageSetting ?? PageSetting.Global;

    var rv = entity.GetRouteKey();
}

<script type="text/html" id="barOpt">
    @if (set.IsReadOnly)
    {
        if (this.Has(PermissionFlags.Detail))
        {
            @*<i class="glyphicon glyphicon-edit" style="color: blue;"></i>
                <a href="@Url.Action("Detail", rv)" class="editcell">查看</a>*@
            <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit">查看</a>
        }
    }
    else if (this.Has(PermissionFlags.Update))
    {
        @*<i class="glyphicon glyphicon-edit" style="color: blue;"></i>
            <a href="@Url.Action("Edit", rv)" class="editcell">编辑</a>*@
        <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="edit">编辑</a>
    }
    else if (this.Has(PermissionFlags.Detail))
    {
        @*<i class="glyphicon glyphicon-edit" style="color: blue;"></i>
            <a href="@Url.Action("Detail", rv)" class="editcell">查看</a>*@
        <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit">查看</a>
    }
    @if (this.Has(PermissionFlags.Delete))
    {
        var fact = ViewBag.Factory as IEntityFactory;
        var fi = (fact == null || fact.Fields == null) ? null : fact.Fields.FirstOrDefault(e => e.Name.EqualIgnoreCase("Deleted", "IsDelete", "IsDeleted"));
        if (fi != null && fi.Type == typeof(Boolean) && (Boolean)entity[fi.Name])
        {
            @*<i class="glyphicon glyphicon-transfer" style="color: green;"></i>
                <a href="@Url.Action("Delete", rv)" data-action="action" data-confirm="确认恢复？">恢复</a>*@
            <a class="layui-btn layui-btn-xs" lay-event="del">删除</a>
        }
        else
        {
            @*<i class="glyphicon glyphicon-remove" style="color: red;"></i>
                <a href="@Url.Action("Delete", rv)" data-action="action" data-confirm="确认删除？">删除</a>*@
            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
        }
    }
</script>
